﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using PMSA.Framework.Database;

/// <summary>
/// Summary description for CBrandFacade
/// </summary>
public class CBrandFacade
{
    private BrandDAL db = new BrandDAL();
    public IList<Brand> List(int pageIndex, int pageMax, int brandId)
    {
        IList<Brand> list = null;
        DataSet ds = new DataSet();
        ds = db.List(pageIndex, pageMax, brandId);
        if (ds != null && ds.Tables.Count > 0)
        {
            list = CDb.MapList<Brand>(ds.Tables[0]);
        }

        return list;
    }
    public Brand Detail(int brandId)
    {
        DataSet ds = new DataSet();
        ds = db.Detail(brandId);
        Brand obj = CDb.Map<Brand>(ds.Tables[0]);
        return obj;
    }
    public Brand Update(int brandid, string brandName, int isActive, string urlLogo)
    {
        DataSet ds = new DataSet();
        ds = db.Update(brandid, brandName, isActive, urlLogo);
        Brand obj = CDb.Map<Brand>(ds.Tables[0]);
        return obj;
    }
    public Brand Insert(string brandName, string logo, int isActive)
    {
        DataSet ds = new DataSet();
        ds = db.Insert(brandName, logo, isActive);
        Brand obj = CDb.Map<Brand>(ds.Tables[0]);
        return obj;
    }
    public Brand UpdateStatusActive(int brandid, int isActive)
    {
        DataSet ds = new DataSet();
        ds = db.UpdateStatusActive(brandid, isActive);
        Brand obj = CDb.Map<Brand>(ds.Tables[0]);
        return obj;
    }


    public string InsertBrandProduct(int brandId, int productId)
    {
        return db.InsertBrandProduct(brandId, productId);
    }
}